package com.dimples.dd.system.mapper;

import com.dimples.dd.common.pojo.PageResult;
import com.dimples.dd.mybatis.core.query.LambdaQueryWrapperX;
import com.dimples.dd.system.model.entity.SystemDictTypeDO;
import com.dimples.dd.system.model.query.DictTypePageQuery;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SystemDictTypeMapper extends com.dimples.dd.mybatis.core.mapper.BaseMapperX<SystemDictTypeDO> {
    /**
     * 分页查询字典类型
     *
     * @param queryParams 查询参数
     * @return PageResult
     */
    default PageResult<SystemDictTypeDO> selectPage(DictTypePageQuery queryParams) {
        return selectPage(queryParams, new LambdaQueryWrapperX<SystemDictTypeDO>()
                .likeIfPresent(SystemDictTypeDO::getName, queryParams.getName())
                .likeIfPresent(SystemDictTypeDO::getType, queryParams.getType())
                .eqIfPresent(SystemDictTypeDO::getStatus, queryParams.getStatus())
                .betweenIfPresent(SystemDictTypeDO::getCreateTime, queryParams.getCreateTime())
                .orderByDesc(SystemDictTypeDO::getId));
    }

    /**
     * 根据字典类型名称查询字典类型
     *
     * @param name 字典类型名称
     * @return SystemDictTypeDO
     */
    default SystemDictTypeDO selectByName(String name) {
        return selectOne(SystemDictTypeDO::getName, name);
    }

    /**
     * 根据字典类型编码查询字典类型
     *
     * @param type 字典类型编码
     * @return SystemDictTypeDO
     */
    default SystemDictTypeDO selectByType(String type) {
        return selectOne(SystemDictTypeDO::getType, type);
    }
}